using fan3dTouch
using gfx
using gfx2
using gfx2Imp

using chunmapModel
using chunmapView
using chunmapTouch
using concurrent

class CanvasTest
{
  Void main()
  {
    Gfx2.setEngine("SWT")
    Actor.locals["fan3dTouch.NativeViewFactory"] = FwtViewFactory()

    map := MapCanvas
    {
      size = Size(900,600)
      layer0 := VectorLayer.makeUri((this.typeof->sourceFile.toStr.toUri + `data/cntry02/cntry02.shp`))
      layers.add(layer0)
      fullView
    }

    zoomIn := Button
    {
      it.onAction.add |e|
      {
        x := map.viewPort.x2World((map.size.w/2).toFloat)
        y := map.viewPort.y2World((map.size.h/2).toFloat)
        cmd := ZoomCommand(map, 2f, x, y)
        map.executeCommand(cmd)
        map.renderMap
      }
      pos = gfx::Point(10, 10)
      text = "+"
    }

    zoomOut := Button
    {
      it.onAction.add |e|
      {
        x := map.viewPort.x2World((map.size.w/2).toFloat)
        y := map.viewPort.y2World((map.size.h/2).toFloat)
        cmd := ZoomCommand(map, 0.5f, x, y)
        map.executeCommand(cmd)
        map.renderMap
      }
      pos = gfx::Point(70, 10)
      text = "-"
    }

    map.add(zoomIn)
    map.add(zoomOut)

    View
    {
      size = Size(900,600)
      doubleBuffer
      map,
    }.show
  }
}